package io;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

public class IODemo10 {
    public static void main(String[] args) {
        //使用字符流读取文件内容
        try (Reader reader = new FileReader("./test.txt")){
            //读取文件
            while (true) {
                char[] buffer = new char[1024];
                int n = reader.read(buffer);
                if(n == -1) {
                    break;
                }
                String s = new String(buffer,0,n);//构造Sring
                System.out.println(s);

//                for (int i = 0; i < n; i++) {
//                    System.out.print(buffer[i]);
//                    System.out.print(" ");
//                }
            }

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
